package com.github.pig.nideshop.controller.user;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.github.pig.common.util.ZyResult;
import com.github.pig.nideshop.entity.NideshopAdmin;
import com.github.pig.nideshop.entity.NideshopSubscribe;
import com.github.pig.nideshop.service.INideshopAdminService;
import com.github.pig.nideshop.service.INideshopSubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  管理员前端控制器
 * </p>
 *
 * @author J神
 * @since 2018-06-11
 */
@RestController
@RequestMapping("/admins")
public class NideshopAdminController {
    @Autowired
    private INideshopAdminService nideshopAdminService;
    @Autowired
    private INideshopSubscribeService nideshopSubscribeService;
    /**
     * 员工列表
     */
    @GetMapping
    public ZyResult admins(NideshopAdmin nideshopAdmin, Page page){
        return  ZyResult.ok(nideshopAdminService.selectPage(page,new EntityWrapper<>(nideshopAdmin)));
    }
    /**
     * 员工详情
     */
    @GetMapping("{id}")
    public ZyResult admin(String id){
        //获取员工基本信息
        //获取员工的可服务项目
        //获取员工评价
        return ZyResult.ok();
    }
    @GetMapping("ailviliableInfo")
    public ZyResult ailviliableTime(NideshopSubscribe nideshopSubscribe){
        //计算可服务时间
        Map map=new HashMap<>();
        map.put("unailviliableTime",nideshopSubscribeService.allowTime(nideshopSubscribe));
        map.put("userInfo",nideshopAdminService.selectById(nideshopSubscribe.getAdminId()));
        return ZyResult.ok(map);
    }
}

